<template>
  <div style="font-size: 12px;line-height: 60px; display: flex">
    <div style="flex: 1; font-size: 20px;">
      <span :class="collapseBtnClass" style="cursor: pointer" @click="collapse"></span>
      <el-breadcrumb separator="/" style="display: inline-block; margin-left: 10px">
        <el-breadcrumb-item :to="'/'">首页</el-breadcrumb-item>
        <el-breadcrumb-item>{{ currentPathName }}</el-breadcrumb-item>
      </el-breadcrumb>
    </div>

    <el-dropdown style="width: 150px; cursor: pointer;text-align: right">

      <div style="display: inline-block;">
        <el-image :src="user.avatarUrl"
                  style="width: 40px;height: 40px;border-radius: 10%;  position: relative; top: 10px; right: 5px">
        </el-image>
        <span>{{ user.nickname }}</span><i class="el-icon-arrow-down" style="margin-left: 5px"></i>
      </div>

      <el-dropdown-menu slot="dropdown" style="text-align: center;">
        <el-dropdown-item style="font-size: 14px; padding: 5px 0;">
          <router-link to="/password">
            <span style="text-decoration: none;color: black">修改密码</span>
          </router-link>
        </el-dropdown-item>
        <el-dropdown-item style="font-size: 14px; padding: 5px 0;width: 85px">
          <router-link to="/person" style="text-decoration-line: none;color: black">个人信息</router-link>
        </el-dropdown-item>
        <el-dropdown-item style="font-size: 14px; padding: 5px 0">
          <span style="text-decoration: none;color: black" @click="logout">退出</span>
        </el-dropdown-item>
      </el-dropdown-menu>
    </el-dropdown>


  </div>
</template>

<script>
export default {
  name: "Header",
  //数据接收
  props: {
    collapseBtnClass: {
      type: String,
      default: "el-icon-arrow-right"
    },
    user: Object,
  },
  data() {
    return {
      //   user: localStorage.getItem("user") ? JSON.parse(localStorage.getItem("user")) : {},//获取用户信息
    }
  },

  methods: {
    // 折叠菜单
    collapse() {
      this.$emit("asideCollapse");//触发父组件的事件
    },
    // 退出登录
    logout() {
      this.$store.commit("logout");
      this.$message.success("退出成功")
    }
  },
  //计算属性
  computed: {
    //获取当前路由的名称
    currentPathName() {
      return this.$store.state.currentPathName;//获取当前路由的名称 监听的数据
    }
  }
}
</script>

<style scoped>

</style>